#!/sbin/openrc-run

NAME=sntpc
DAEMON=/usr/sbin/$NAME

depend() {
	need net
	after firewall
}

start() {
	local msg opts
	if [ "$SNTPC_INTERVAL" = "0" ]; then
		msg="Setting time from NTP source"
	else
		msg="Starting ${NAME}"
		opts="-d"
	fi
	ebegin "$msg"
		start-stop-daemon --start --quiet \
			--exec ${DAEMON} -- \
			-i ${SNTPC_INTERVAL} $opts ${SNTPC_HOST}
	eend $?
}

stop() {
	ebegin "Stopping ${NAME}"
		start-stop-daemon --stop --quiet \
			--exec ${DAEMON} 
	eend $?
}
